package blurimage

import (
	"code.google.com/p/jesus-1496/models"
	"code.google.com/p/jesus-1496/utils/jsonrpcclient"
)

type blurImageArgs struct {
	FileIn  string
	FileOut string
	Humans  []models.Human
	Radius  int
}

type BlurImageError struct {
	errorString string
}

func (b *BlurImageError) Error() string {
	return b.errorString
}

func NewBlurImageError(errorString string) error {
	if errorString == "" {
		return nil
	} else {
		return &BlurImageError{errorString}
	}
}

type blurImageResponse string

func BlurImage(fileIn string, fileOut string, humans []models.Human, radius int) error {
	args := blurImageArgs{fileIn, fileOut, humans, radius}
	reply := ""
	err := jsonrpcclient.Call("blur_image", args, &reply)
	if err != nil {
		return err
	}
	return NewBlurImageError(reply)
}
